package com.tpshion.cloud.auth.domain.dto;

import com.tpshion.cloud.common.support.Constants;
import org.springframework.util.StringUtils;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

@Valid
public class CheckPhoneDto {

    @Size(max = 64, message = "用户id长度不能超过64")
    private String userId;

    @NotEmpty(message = "手机号不能为空")
    @Pattern(regexp = Constants.PHONE_REGEXP, message = "手机号不正确")
    private String phone;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Override
    public String toString() {
        return "CheckPhoneDto{" +
                "userId='" + userId + '\'' +
                ", phone='" + phone + '\'' +
                '}';
    }

    public void init(){
        this.userId = StringUtils.isEmpty(this.userId) ? this.userId : this.userId.trim();
        this.phone = StringUtils.isEmpty(this.phone) ? this.phone : this.phone.trim();
    }
}
